package com.goodvideotutorials.spring.controllers;

import javax.mail.MessagingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.goodvideotutorials.spring.dto.SignupForm;
import com.goodvideotutorials.spring.mail.MailSender;

@Controller
public class RootController {

	@Autowired
	private MailSender smtpMailSender;

	@RequestMapping("/signup")
	public String signup(Model model) {

		model.addAttribute("signupForm", new SignupForm());
		return "signup";
	}

	@RequestMapping("/")
	public String hello() {
		return "hello";
	}
	
	@RequestMapping("/send")
	public String sendMail() throws MessagingException{
		smtpMailSender.send("mmotieian@yahoo.com", "Spring Mail Test", "Salam, This is a test");
		return "hello";
	}

}
